import react from '@vitejs/plugin-react-swc'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig, loadEnv } from 'vite'


const config = loadEnv('development', './')

export default defineConfig({
  plugins: [react(), AutoImport({
    imports: ['react'],
    dts: 'types/auto-imports.d.ts',
  }),],

  server: {
    host: '0.0.0.0',
    port: 3797,
    open: false,
    base: config.VITE_APP_BASE_PATH,
    proxy: {
      '^/api': {
        target: 'http://xuanxiaoqian.com:9987',
        changeOrigin: true,
        rewrite: (path) => path.replace('/api/', ''),
      },
    },
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, './src'),
    },
  },
})
